/*成本中心管理*/
queryPurchaseLimitFn();
function queryPurchaseLimitFn() {
    var params = {
        "customerCode": customerCode
    }
    web.doAjax(root.inter.getCustomerAmountLimit, 'post',params, function (data) {
        if(data.errorCode == 0){
            console.log(data);
            $("input:radio[name='purchaseLimitRadio'][value='" + data.data.limitAmountType + "']").attr("checked", true);
            if(data.data.limitAmountType == 0){
                $(".purchaseLimitInp").attr("disabled", "disabled").val('');
                return;
            }
            $(".purchaseLimitInp").val(data.data.limitAmount);
        }else {
            $.Huimodalalert(data.msg,2000);
        }
    },1);
}
$("input:radio[name='purchaseLimitRadio']").change(function () {
    console.log(this.value)
    if(this.value == 0){
        $(".purchaseLimitInp").attr("disabled", "disabled").val('');
    }else {
        $(".purchaseLimitInp").removeAttr("disabled");
    }
})
function purchaseLimitFn() {
    var params = {
        "customerCode": customerCode,
        "customerId": customerId,
        "limitAmountType": $("input:radio[name='purchaseLimitRadio']:checked").val(),//采购限额类型,
        "limitAmount":$(".purchaseLimitInp").val(),//采购限额
    }
    if(params.limitAmountType == ''){
        $.Huimodalalert('请选择采购限额类型',2000);
        return;
    }
    if(params.limitAmountType == '1' && params.limitAmount == ''){
        $.Huimodalalert('请输入采购限额',2000);
        return;
    }
    web.doAjax(root.inter.saveCustomerAmountLimit, 'post',params, function (data) {
        if(data.errorCode == 0){
            $.Huimodalalert(data.msg,2000);
            queryPurchaseLimitFn();
        }else {
            $.Huimodalalert(data.msg,2000);
        }
    },1);
}
function mathFloor (num, digit) {
    return Math.floor(num * Math.pow(10, digit)) / Math.pow(10, digit).toFixed(2);
}
